<template lang="pug">
  .notice
    .addcompany
      el-form(:model="ruleForm"  :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm")
        el-form-item(label="行业名称" prop="name")
          el-input(v-model="ruleForm.name")
    .btns
      el-button(type="danger" @click="submitForm('ruleForm')") 添加
      el-button(@click="$router.go(-1)") 取消
</template>
<script>
import qs from 'qs';
export default {
  name:'notice',
  data(){
    return{
      ruleForm:{
        name:'',
      },
      rules: {
        name: [
          { required: true, message: '请输入行业名称', trigger: 'blur' },
        ]
      }
    }
  },
  mounted(){
    // console.log(qs)
  },
  methods:{
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.adddivide()
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    async adddivide(){
      let list = {
        industryName:this.ruleForm.name,
        industryCode:'123'
      }
      console.log(list)
      let res = await this.$ajax.post('xyssoManager/industry/insert',list)
      let data = res.data
      if(data.code==200){
        this.$message.success('添加成功')
        this.$router.push('divide')
      }
    }
  }
}
</script>
<style lang="stylus" scoped>
.notice
  width 1100px
  margin 0 auto
  .addcompany
    padding 40px 0
    width 1100px
    background #ffffff
    .demo-ruleForm
      margin 0 auto
      width 350px
      .el-input
      .el-select
        width 100%
.btns
  margin-top 10px
  text-align  right
  button
    width 76px
</style>


